﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using BooInterpreter = Boo.Lang.Interpreter;

namespace TestApp
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            SyntaxTextBox.SyntaxLexer = new Boo.BooTokenParser();
            BooInterpreter.InteractiveInterpreter i = new global::Boo.Lang.Interpreter.InteractiveInterpreter();
             
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://wpfsyntax.codeplex.com/");
        }

        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void LightThemeMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SyntaxTextBox.Style = FindResource("LightTheme") as Style;
            LightThemeMenuItem.IsChecked = true;
            DarkThemeMenuItem.IsChecked = false;
            ExperimentalThemeMenuItem.IsChecked = false;
        }

        private void DarkThemeMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SyntaxTextBox.Style = FindResource("DarkTheme") as Style;
            LightThemeMenuItem.IsChecked = false;
            DarkThemeMenuItem.IsChecked = true;
            ExperimentalThemeMenuItem.IsChecked = false;
        }

        private void ExperimentalThemeMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SyntaxTextBox.Style = FindResource("ExperimentalTheme") as Style;
            LightThemeMenuItem.IsChecked = false;
            DarkThemeMenuItem.IsChecked = false;
            ExperimentalThemeMenuItem.IsChecked = true;
        }

        private void IronPythonMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SyntaxTextBox.SyntaxLexer = new IronPython.IronPythonTokenParser();
            IronPythonMenuItem.IsChecked = true;
            BooMenuItem.IsChecked = false;
        }

        private void BooMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SyntaxTextBox.SyntaxLexer = new Boo.BooTokenParser();
            IronPythonMenuItem.IsChecked = false;
            BooMenuItem.IsChecked = true;
        }

        private void IronPytonExampleMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SyntaxTextBox.Text = Resource.IronPythonCode;
        }

        private void BooExampleMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SyntaxTextBox.Text = Resource.BooCode;
        }

        private void SearchTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                string[] words = SearchTextBox.Text.Split(',', ' ', ';', '-');
                SyntaxTextBox.HighlightText.Clear();

                foreach (string word in words)
                    SyntaxTextBox.HighlightText.Add(word);
            }
        }
    }
}
